<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    //find() 找到满足条件的一个立即返回
    //findIndex() 找到满足条件的一个，立即返回索引

    const a = [1, 2, 3, 5].find((value, index, arr) => {
      // console.log(value, index, arr)
      console.log(this);
      return value>1
    },document);
    const b= [1, 2, 3, 5].findIndex((value, index, arr) => {
      // console.log(value, index, arr)
      // console.log(this);
      return value>1
    },document);
    console.log(a);
    console.log(b);

    const p=[{name:'a',age:1},{name:'b',age:2},{name:'c',age:1}]
    console.log(p.find(value=>value.name=='a')); 
    console.log(p.findIndex(value=>value.name=='a')); 
    

  </script>
</body>

</html>